<?php
/**
 * Copyright (c) [2019] [吴跃忠]
 * [selibra] is licensed under the Mulan PSL v1.
 * You can use this software according to the terms and conditions of the Mulan PSL v1.
 * You may obtain a copy of Mulan PSL v1 at:
 * http://license.coscl.org.cn/MulanPSL
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v1 for more details.
 */

namespace Selibra\Http\Command;


use Selibra\Tools\Console;
use Selibra\Di\Annotations\Autowired;
use Selibra\Command\Annotations\Command;
use Selibra\Http\HttpControl;
use Selibra\Http\Server\HttpServer;
use Symfony\Component\Console\Command\Command as ConsoleCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;


/**
 * Class HttpCommand
 * @package selibra\http
 */
#[Command("http")]
class HttpStartCommand extends ConsoleCommand
{

    /**
     * @var HttpServer
     */
    #[Autowired]
    protected HttpServer $httpServer;


    /**
     * @var HttpControl
     */
    #[Autowired]
    protected HttpControl $httpControl;


    protected function configure()
    {
        $this->setName('http:start');
    }


    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return int
     * @throws \Selibra\Di\Container\Exception\MetadataNotFoundException
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // 启动
        echo "
   _____        __     _  __                    __  __ __   __         _____                               
  / ___/ ___   / /    (_)/ /_   _____ ____ _   / / / // /_ / /_ ____  / ___/ ___   _____ _   __ ___   _____
  \__ \ / _ \ / /    / // __ \ / ___// __ `/  / /_/ // __// __// __ \ \__ \ / _ \ / ___/| | / // _ \ / ___/
 ___/ //  __// /___ / // /_/ // /   / /_/ /  / __  // /_ / /_ / /_/ /___/ //  __// /    | |/ //  __// /    
/____/ \___//_____//_//_.___//_/    \__,_/  /_/ /_/ \__/ \__// .___//____/ \___//_/     |___/ \___//_/     
                                                            /_/                                             \n";
        $this->httpControl->setHttpServer($this->httpServer)->start();
        return 0;
    }

}
